package ml.ml.Dao;

import interfaces.CRUD;

import java.util.List;

import ml.ml.Clases.Transaccionista;

import org.easycassandra.persistence.EasyCassandraManager;
import org.easycassandra.persistence.Persistence;

/**
 * TODO: description
 */
public abstract class SuperDAO implements CRUD<Transaccionista> {

    private static final long serialVersionUID = 1L;

    /**
     * The Manager Object
     */
    private Persistence persistence;

    public SuperDAO() {

        this.persistence = EasyCassandraManager.getPersistence("mlp", "localhost", 9160);
    }

    public void create(final Transaccionista bean) {

        this.persistence.insert(bean);

    }

    public void remove(final Transaccionista bean) {

        this.persistence.delete(bean);
    }

    public void remove(final Long id) {
        this.persistence.deleteByKeyValue(id, Transaccionista.class);
    }

    public void update(final Transaccionista bean) {
        this.persistence.update(bean);
    }

    public Transaccionista retrieve(final Object id) {
        return (Transaccionista) this.persistence.findByKey(id, Transaccionista.class);
    }

    @SuppressWarnings("unchecked")
    public List<Transaccionista> listAll() {
        return this.persistence.findAll(Transaccionista.class);
    }

    @SuppressWarnings("unchecked")
    public List<Transaccionista> listByIndex(final Object index) {

        return this.persistence.findByIndex(index, Transaccionista.class);

    }

}
